<?php require_once('../Connections/aciitu.php'); ?>
<?php
// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Make unified connection variable
$conn_aciitu = new KT_connection($aciitu, $database_aciitu);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listRsSlide1 = new TFI_TableFilter($conn_aciitu, "tfi_listRsSlide1");
$tfi_listRsSlide1->addColumn("titulo", "STRING_TYPE", "titulo", "%");
$tfi_listRsSlide1->addColumn("link", "STRING_TYPE", "link", "%");
$tfi_listRsSlide1->addColumn("arquivo", "STRING_TYPE", "arquivo", "%");
$tfi_listRsSlide1->addColumn("nome", "STRING_TYPE", "nome", "%");
$tfi_listRsSlide1->Execute();

// Sorter
$tso_listRsSlide1 = new TSO_TableSorter("RsSlide", "tso_listRsSlide1");
$tso_listRsSlide1->addColumn("titulo");
$tso_listRsSlide1->addColumn("link");
$tso_listRsSlide1->addColumn("arquivo");
$tso_listRsSlide1->addColumn("nome");
$tso_listRsSlide1->setDefault("titulo");
$tso_listRsSlide1->Execute();

// Navigation
$nav_listRsSlide1 = new NAV_Regular("nav_listRsSlide1", "RsSlide", "../", $_SERVER['PHP_SELF'], 20);

//NeXTenesio3 Special List Recordset
$maxRows_RsSlide = $_SESSION['max_rows_nav_listRsSlide1'];
$pageNum_RsSlide = 0;
if (isset($_GET['pageNum_RsSlide'])) {
  $pageNum_RsSlide = $_GET['pageNum_RsSlide'];
}
$startRow_RsSlide = $pageNum_RsSlide * $maxRows_RsSlide;

// Defining List Recordset variable
$NXTFilter_RsSlide = "1=1";
if (isset($_SESSION['filter_tfi_listRsSlide1'])) {
  $NXTFilter_RsSlide = $_SESSION['filter_tfi_listRsSlide1'];
}
// Defining List Recordset variable
$NXTSort_RsSlide = "titulo";
if (isset($_SESSION['sorter_tso_listRsSlide1'])) {
  $NXTSort_RsSlide = $_SESSION['sorter_tso_listRsSlide1'];
}
mysql_select_db($database_aciitu, $aciitu);

$query_RsSlide = "SELECT slide.id, slide.titulo, slide.link, slide.arquivo, status.nome FROM (slide LEFT JOIN status ON status.id=slide.status) WHERE  {$NXTFilter_RsSlide}  ORDER BY  {$NXTSort_RsSlide} ";
$query_limit_RsSlide = sprintf("%s LIMIT %d, %d", $query_RsSlide, $startRow_RsSlide, $maxRows_RsSlide);
$RsSlide = mysql_query($query_limit_RsSlide, $aciitu) or die(mysql_error());
$row_RsSlide = mysql_fetch_assoc($RsSlide);

if (isset($_GET['totalRows_RsSlide'])) {
  $totalRows_RsSlide = $_GET['totalRows_RsSlide'];
} else {
  $all_RsSlide = mysql_query($query_RsSlide);
  $totalRows_RsSlide = mysql_num_rows($all_RsSlide);
}
$totalPages_RsSlide = ceil($totalRows_RsSlide/$maxRows_RsSlide)-1;
//End NeXTenesio3 Special List Recordset

$nav_listRsSlide1->checkBoundries();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style>

<!--lightbox-->
<script type="text/javascript" src="../ferramentas/lightbox/js/prototype.js"></script>
<script type="text/javascript" src="../ferramentas/lightbox/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="../ferramentas/lightbox/js/lightbox.js"></script>
<link rel="stylesheet" href="../ferramentas/lightbox/css/lightbox.css" type="text/css" media="screen" />
<!--fim lightbox-->

<link href="../css/css_admin.css" rel="stylesheet" type="text/css" />
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script>
<script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: false,
  duplicate_navigation: false,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="texto_barra">
  <tr>
    <td>
      <div class="KT_tng" id="listRsSlide1">
        <h1> BANNERS
          <?php
  $nav_listRsSlide1->Prepare();
  require("../includes/nav/NAV_Text_Statistics.inc.php");
?>
        </h1>
        <div class="KT_tnglist">
          <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
            <div class="KT_options"> <a href="<?php echo $nav_listRsSlide1->getShowAllLink(); ?>"><?php echo NXT_getResource("Show"); ?>
              <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listRsSlide1'] == 1) {
?>
                <?php echo $_SESSION['default_max_rows_nav_listRsSlide1']; ?>
                <?php 
  // else Conditional region1
  } else { ?>
                <?php echo NXT_getResource("all"); ?>
                <?php } 
  // endif Conditional region1
?>
              <?php echo NXT_getResource("records"); ?></a> &nbsp;
              &nbsp; </div>
            <table cellpadding="2" cellspacing="0" class="KT_tngtable">
              <thead>
                <tr class="KT_row_order">
                  <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
                  </th>
                  <th id="titulo" class="KT_sorter KT_col_titulo <?php echo $tso_listRsSlide1->getSortIcon('titulo'); ?>"> <a href="<?php echo $tso_listRsSlide1->getSortLink('titulo'); ?>">Titulo</a> </th>
                  <th id="link" class="KT_sorter KT_col_link <?php echo $tso_listRsSlide1->getSortIcon('link'); ?>"> <a href="<?php echo $tso_listRsSlide1->getSortLink('link'); ?>">Link</a> </th>
                  <th id="arquivo" class="KT_sorter KT_col_arquivo <?php echo $tso_listRsSlide1->getSortIcon('arquivo'); ?>"> <a href="<?php echo $tso_listRsSlide1->getSortLink('arquivo'); ?>">Arquivo</a> </th>
                  <th id="nome" class="KT_sorter KT_col_nome <?php echo $tso_listRsSlide1->getSortIcon('nome'); ?>"> <a href="<?php echo $tso_listRsSlide1->getSortLink('nome'); ?>">Status</a> </th>
                  <th>&nbsp;</th>
                </tr>
              </thead>
              <tbody>
                <?php if ($totalRows_RsSlide == 0) { // Show if recordset empty ?>
                  <tr>
                    <td colspan="6"><?php echo NXT_getResource("The table is empty or the filter you've selected is too restrictive."); ?></td>
                  </tr>
                  <?php } // Show if recordset empty ?>
                <?php if ($totalRows_RsSlide > 0) { // Show if recordset not empty ?>
                  <?php do { ?>
                    <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
                      <td><input type="checkbox" name="kt_pk_slide" class="id_checkbox" value="<?php echo $row_RsSlide['id']; ?>" />
                        <input type="hidden" name="id" class="id_field" value="<?php echo $row_RsSlide['id']; ?>" /></td>
                      <td><div class="KT_col_titulo"><?php echo KT_FormatForList($row_RsSlide['titulo'], 20); ?></div></td>
                      <td><div class="KT_col_link"><?php echo KT_FormatForList($row_RsSlide['link'], 20); ?></div></td>
                      <td>
                      <?php if($row_RsSlide['arquivo'] <> ""){ ?>
                      <a href="../fotos/intro/<?php echo $row_RsSlide['arquivo']; ?>" rel="lightbox" title="<?php echo $row_RsSlide['titulo']; ?>">
                      <img src="../imagens/icones/zoom.png" border="0" title="Ver Imagem">
                      </a>
                      <?php } else { ?>
                      <img src="../imagens/icones/no_foto.png" border="0" title="Sem Imagem">
                      <?php } ?>  
                      </td>
                      <td><div class="KT_col_nome"><?php echo KT_FormatForList($row_RsSlide['nome'], 20); ?></div></td>
                      <td><a class="KT_edit_link" href="Admin_Editar_Banner.php?id=<?php echo $row_RsSlide['id']; ?>&amp;KT_back=1"><?php echo NXT_getResource("edit_one"); ?></a> <a class="KT_delete_link" href="#delete"><?php echo NXT_getResource("delete_one"); ?></a></td>
                    </tr>
                    <?php } while ($row_RsSlide = mysql_fetch_assoc($RsSlide)); ?>
                  <?php } // Show if recordset not empty ?>
              </tbody>
            </table>
            <div class="KT_bottomnav">
              <div>
                <?php
            $nav_listRsSlide1->Prepare();
            require("../includes/nav/NAV_Text_Navigation.inc.php");
          ?>
              </div>
            </div>
            <div class="KT_bottombuttons">
              <div class="KT_operations"> <a class="KT_edit_op_link" href="#" onClick="nxt_list_edit_link_form(this); return false;"><?php echo NXT_getResource("edit_all"); ?></a> <a class="KT_delete_op_link" href="#" onClick="nxt_list_delete_link_form(this); return false;"><?php echo NXT_getResource("delete_all"); ?></a> </div>
              <span>&nbsp;</span>
              <select name="no_new" id="no_new">
                <option value="1">1</option>
                <option value="3">3</option>
                <option value="6">6</option>
              </select>
              <a class="KT_additem_op_link" href="Admin_Editar_Banner.php?KT_back=1" onClick="return nxt_list_additem(this)"><?php echo NXT_getResource("add new"); ?></a> </div>
          </form>
        </div>
        <br class="clearfixplain" />
      </div>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($RsSlide);
?>
